package com.project.controller;

import com.project.bean.User;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.time.LocalDate;

/**
 * @author lyl
 * description:
 */
@Controller
@RequestMapping("test")
public class TestController {

    @RequestMapping("checkName")
    public void checkName(String name, HttpServletResponse response) throws IOException {
        if ("java".equals(name)) {
            response.getWriter().print("no");
        } else {
            response.getWriter().print("yes");
        }
    }

    @RequestMapping("getString")
    @ResponseBody //返回的字符串不再是url地址而是字符串
    public String getString() {
//        return "/html/add.html";
        return "ok中国人";
    }

    @RequestMapping("getUser")
    @ResponseBody
    public User getUser() {
        return new User(1, "刘三", LocalDate.parse("1998-03-01"));
    }

    @RequestMapping("getX")
    @ResponseBody
    public int getX() {
        return 3;
    }


}
